#pragma once
#pragma warning(disable:4996)       // disable checked iterator errors http://msdn.microsoft.com/en-us/library/aa985965(VS.80).aspx 

//
// Copyright (C) 2011 - 2013 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1

#include <Macros.h>
#include <ValueHelpers.h>
#include <Settings.h>

#include <gen/QL/Processes/GeneralizedBlackScholesProcess.h>
#pragma unmanaged 
#include <ql\experimental\processes\vegastressedblackscholesprocess.hpp>
#include <boost/smart_ptr/detail/spinlock.hpp>
#pragma managed 

using namespace System;
using namespace QuantLib;
using namespace Cephei;
using namespace Cephei::Core;
using namespace PLATFORM::Collections;

using namespace Cephei::QL;
using namespace Cephei::QL::Termstructures;
using namespace Cephei::QL::Termstructures::Volatility::Equityfx;
using namespace Cephei::QL::Math;
using namespace Cephei::QL::Processes;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
namespace Cephei { namespace QL { namespace Experimental { namespace Processes {
	//////////////////////////////////////////////////////////////////////////////////////////////
	// implementation of IVegaStressedBlackScholesProcess
	public ref class CVegaStressedBlackScholesProcess  : 
            public CGeneralizedBlackScholesProcess,
            public Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess
	{
	protected: 
		boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess>* _ppVegaStressedBlackScholesProcess;
#ifdef HANDLE
		QuantLib::Handle<QuantLib::VegaStressedBlackScholesProcess>* _phVegaStressedBlackScholesProcess;
#endif
		Object^ _VegaStressedBlackScholesProcessOwner;     // reference to object that manages the storage for this object
	internal:
		CVegaStressedBlackScholesProcess (Cephei::QL::IQuote^ x0, Cephei::QL::Termstructures::IYieldTermStructure^ dividendTS, Cephei::QL::Termstructures::IYieldTermStructure^ riskFreeTS, Cephei::QL::Termstructures::Volatility::Equityfx::IBlackVolTermStructure^ blackVolTS, Microsoft::FSharp::Core::FSharpOption<Double>^ lowerTimeBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ upperTimeBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ lowerAssetBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ upperAssetBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ stressLevel);
        CVegaStressedBlackScholesProcess (boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess>& childNative, Object^ owner);
        CVegaStressedBlackScholesProcess (QuantLib::VegaStressedBlackScholesProcess& childNative, Object^ owner);
        CVegaStressedBlackScholesProcess (CVegaStressedBlackScholesProcess^ copy);
        CVegaStressedBlackScholesProcess (PLATFORM::Type^ t);
#ifdef STRUCT
        CVegaStressedBlackScholesProcess (QuantLib::VegaStressedBlackScholesProcess childNative);
#endif       
#ifdef HANDLE
		CVegaStressedBlackScholesProcess (QuantLib::Handle<QuantLib::VegaStressedBlackScholesProcess>& childNative, Object^ owner);
		CVegaStressedBlackScholesProcess (QuantLib::Handle<QuantLib::VegaStressedBlackScholesProcess> childNative);
#endif
		virtual ~CVegaStressedBlackScholesProcess ();
		!CVegaStressedBlackScholesProcess ();

	internal:
		QuantLib::VegaStressedBlackScholesProcess& GetReference ();
		boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess>& GetShared ();
		QuantLib::VegaStressedBlackScholesProcess* GetPointer ();
        void SetVegaStressedBlackScholesProcess (boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess> native)
        {
            if (_ppVegaStressedBlackScholesProcess != NULL)
                delete _ppVegaStressedBlackScholesProcess;
            _ppVegaStressedBlackScholesProcess = new boost::shared_ptr<QuantLib::VegaStressedBlackScholesProcess> (native);
            SetGeneralizedBlackScholesProcess (boost::dynamic_pointer_cast<QuantLib::GeneralizedBlackScholesProcess> (*_ppVegaStressedBlackScholesProcess));
        }
#ifdef HANDLE
		QuantLib::Handle<QuantLib::VegaStressedBlackScholesProcess>& GetHandle ();
#endif
		virtual bool HasNative () override;
    public:
		virtual Double Diffusion (Double t, Double x) ;
        property Double GetLowerAssetBorderForStressTest 
        {
		    virtual Double get () ;
        }
        property Double GetLowerTimeBorderForStressTest 
        {
		    virtual Double get () ;
        }
        property Double GetStressLevel 
        {
		    virtual Double get () ;
        }
        property Double GetUpperAssetBorderForStressTest 
        {
		    virtual Double get () ;
        }
        property Double GetUpperTimeBorderForStressTest 
        {
		    virtual Double get () ;
        }
		virtual Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ SetLowerAssetBorderForStressTest (Double LAB) ;
		virtual Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ SetLowerTimeBorderForStressTest (Double LTB) ;
		virtual Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ SetStressLevel (Double SL) ;
		virtual Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ SetUpperAssetBorderForStressTest (Double UBA) ;
		virtual Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^ SetUpperTimeBorderForStressTest (Double UTB) ;
    };
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Factory class
//z	[FactoryFor(Core::Generic::ICoCell<Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess^>::typeid)]
	[FactoryFor(Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess::typeid)]
	[FactoryFor(Cephei::QL::Experimental::Processes::IVegaStressedBlackScholesProcess_Factory::typeid)]
	public ref class CVegaStressedBlackScholesProcess_Factory sealed : public IVegaStressedBlackScholesProcess_Factory
	{
	public:
        virtual IVegaStressedBlackScholesProcess^ Create (Cephei::QL::IQuote^ x0, Cephei::QL::Termstructures::IYieldTermStructure^ dividendTS, Cephei::QL::Termstructures::IYieldTermStructure^ riskFreeTS, Cephei::QL::Termstructures::Volatility::Equityfx::IBlackVolTermStructure^ blackVolTS, Microsoft::FSharp::Core::FSharpOption<Double>^ lowerTimeBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ upperTimeBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ lowerAssetBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ upperAssetBorderForStressTest, Microsoft::FSharp::Core::FSharpOption<Double>^ stressLevel);
    };
   
/*Cephei*/ } /*QL*/ } /*Experimental*/ } /*Processes */}
